<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns="http://www.w3.org/1999/html">
<head>
    <th:block th:include="include :: header('履历本')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
    <style type="text/css">
        .select-list li label:not(.radio-box) {
            width: 110px;
            text-align: right;
        }
        .select-list li {
            color: #333;
            margin: 5px 55px 5px 0px;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label class="font-noraml">测试台：</label>
                            <select class="form-control" name="stationName" id="stationName">
                                <option value="">请选择</option>
                                <option th:each="stationName:${stationNameList}" th:value="${stationName}"
                                        th:text="${stationName}"></option>
                            </select>
                        </li>
                        <li>
                            <label>时间：</label>
                            <input style="width: 290px" type="text" id="startTime" name="params[beginTime]" placeholder="开始时间 - 结束时间">
                        </li>
                        <li>
                            <label class="font-noraml">履历本名称：</label>
                            <select class="form-control" name="resumeName" id="resumeName">
                                <option value="">请选择</option>
                                <option th:each="resumeName:${resumeNameList}" th:value="${resumeName}"
                                        th:text="${resumeName}"></option>
                            </select>
                        </li>
                        <li>
                            <label class="font-noraml">履历本编号：</label>
                            <select class="form-control" name="resumeNo" id="resumeNo">
                                <option value="">请选择</option>
                                <option th:each="resumeNo:${resumeNoList}" th:value="${resumeNo}"
                                        th:text="${resumeNo}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:resumeinfo:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:resumeinfo:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:resumeinfo:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:resumeinfo:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: bootstrap-select-js" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:resumeinfo:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:resumeinfo:remove')}]];
    var prefix = ctx + "system/resumeinfo";

    $(function() {
        // initDate();

        layui.use('laydate', function() {
            var laydate = layui.laydate;
            laydate.render({
                elem: '#startTime',
                type: 'datetime',
                trigger: 'click',
                range: true
            });
        });

        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "履历本",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '序号',
                    visible: false
                },
                {
                    field: 'stationName',
                    title: '测试台'
                },
                {
                    field: 'resumeName',
                    title: '履历本名称'
                },
                {
                    field: 'resumeNo',
                    title: '履历本编号'
                },
                {
                    field: 'resumeTime',
                    title: '时间'
                },
                {
                    title: '查看',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.resumeName != undefined && row.resumeName != null && row.resumeName != '') {
                            // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.preview(\'' + row.resumeName + '\')"><i class="fa fa-edit"></i>查看</a> ');
                            actions.push('<a class="btn btn-success btn-xs  href="javascript:void(0)" onclick="viewFileInfo(\'' + row.resumeName + '\')"><i class="fa fa-edit"></i>查看</a> ');
                        } else {
                            actions.push('<a style="background-color: #606060" class="btn btn-success btn-xs " href="javascript:void(0)"><i class="fa fa-edit"></i>查看</a> ');
                        }
                        return actions.join('');
                    }

                }]
        };
        $.table.init(options);
    });

    function viewFileInfo(fileName){
        table.set();
        open("预览", "viewFileInfo/Resumebooks/" + encodeURI(fileName));
    }

    function initDate() {
        var date1 = new Date();
        date1.setTime(date1.getTime() - 7 * 24 * 60 * 60 * 1000);
        var month1 = date1.getMonth() + 1;
        var day1 = date1.getDate();
        if (date1.getMonth() < 9) {
            month1 = "0" + (date1.getMonth() + 1);
        }
        if(date1.getDate() < 10) {
            day1 = "0" + date1.getDate();
        }
        var startTime = date1.getFullYear() + "-" + month1 + "-" + day1 + " 00:00:00";

        var date2 = new Date();
        date2.setTime(date2.getTime());
        var month2 = date2.getMonth() + 1;
        var day2 = date2.getDate();
        if (date2.getMonth() < 9) {
            month2 = "0" + (date2.getMonth() + 1);
        }
        if(date2.getDate() < 10) {
            day2 = "0" + date2.getDate();
        }
        var endTime = date2.getFullYear() + "-" + month2 + "-" + day2 + " 00:00:00";

        $("#startTime").val(startTime + " - " +endTime);
    }

    function reset() {
        $("#stationName").select2("val", [""]);
        $("#startTime").val("");
        $("#resumeName").select2("val", [""]);
        $("#resumeNo").select2("val", [""]);
    }

    // 弹出层指定宽度
    function open (title, url, width, height, callback) {
        // 如果是移动端，就使用自适应大小弹窗
        if ($.common.isMobile()) {
            width = 'auto';
            height = 'auto';
        }
        if ($.common.isEmpty(title)) {
            title = false;
        }
        if ($.common.isEmpty(url)) {
            url = "/404.html";
        }
        if ($.common.isEmpty(width)) {
            width = 800;
        }
        if ($.common.isEmpty(height)) {
            height = ($(window).height() - 50);
        }
        if ($.common.isEmpty(callback)) {
            callback = function(index, layero) {
                var iframeWin = layero.find('iframe')[0];
                iframeWin.contentWindow.submitHandler(index, layero);
            }
        }
        top.layer.open({
            type: 2,
            area: [width + 'px', height + 'px'],
            fix: false,
            //不固定
            maxmin: true,
            shade: 0.3,
            title: title,
            content: url,
            btn: ['确定', '关闭'],
            // 弹层外区域关闭
            shadeClose: true,
            btn: ['关闭'],
            yes: function (index, layero) {
                $.modal.close(index);
            }
        });
    }
</script>
</body>
</html>